<template>
	<!-- 客户添加 -->
	<div>
		<div class="edit-top">
			<span v-text="conditionType == 1?'满减订单条件设置':'充值送金额条件设置'"></span>
			<i class="el-icon-close" @click="cancel"></i>
		</div>
        <div class="full-reduction">
            <div>
                <span v-text="conditionType == 1?'满':'充值满'"></span>
                <input type="text" v-model="amount">
                <span>元</span>
                <span v-text="conditionType == 1?'减':'赠'"></span>
                <input type="text" v-model="reduceAmount">
                <span>元</span>
            </div>
            <div>
                <el-button size="small" @click="onClick(conditionType)" type="primary">确定</el-button>
            </div>

        </div>
		
	</div>
</template>
<script>
	export default {
        props:['conditionType'],
		data() {
			return {
                amount:'',
                reduceAmount:'',
                list:[1],
			}
		},
		created() {
			
		},
		mounted() {
			
		},
		methods: {
		    cancel(){
                this.$emit('condition',1)
            },
            onClick(type){
                var data = {}
                if(type == 1){
                    data={
                       'creditAmount':this.amount,
                       'thresholdMoney':this.reduceAmount
                    }
                }else{
                    data={
                       'thresholdMoney3':this.amount,
                       'creditAmount3':this.reduceAmount
                    }
                }
                var self = this
                this.$axios.post(this.$global.serverIp + 'frontend/activityRules/saveOrUpdate', data)
                .then(res =>{
                       if(res != ''){
                           var temp = {'amount':this.amount,'reduceAmount':this.reduceAmount,'id':res.data.id}
                           console.log(temp)
                           this.$emit('condition',temp)
                       }
                })
                
            }
		}
	}
	import '@/assets/css/edit.css'
</script>
<style scoped>
    .full-reduction{
        display: flex;
        align-items: center;
        width: 80%;
        margin: 40px auto;
        justify-content: space-between;
        font-size: 16px;
        color: #606b82;
    }
    input{
        width: 130px;
        height: 30px;
        border: 1px solid #eee;
        border-radius: 4px;
        margin: 0 10px;
        padding: 0 10px;
    }
</style>
